/**
 * 2D Water ripple effect
 *
 * Takes the ripple height data from a texture, and writes
 * the new data to the frame buffer (an FBO texture).
 *
 * Requires Shader Model 2.0
 **/

//uniform mat4 gl_ModelViewProjectionMatrix;

uniform sampler2D	gHeightMap;
uniform vec3		gScale;

//attribute vec4 gl_Vertex;
//attribute vec4 gl_Position;

float sample(vec3 pos) {
	return length(texture2D(gHeightMap, vec2(pos.x * gScale.x, pos.z * gScale.z)).rgb) * gScale.y;
}

void main() {
	float h = sample(gl_Vertex);
	
	// Only using RGB components, so take three
	h = sqrt((h * h) / 3);
	gl_Color = vec4(h, h, h, h);
}
